package com.yuan.yblog.common.exception;

import com.yuan.yblog.common.api.ResultCode;
import lombok.Getter;

/**
 * API接口异常
 */
@Getter
public class ApiException extends RuntimeException{

    private ResultCode resultCode;

    /**
     * 构造：API请求异常
     * @param resultCode 响应状态码及其信息
     */
    public ApiException(ResultCode resultCode) {
        super(resultCode.getMessage());
        this.resultCode = resultCode;
    }

    /**
     * 构造：API请求异常
     * @param message 错误信息
     */
    public ApiException(String message) {
        super(message);
    }

    /**
     * 构造：API请求异常
     * @param cause Throwable错误对象
     */
    public ApiException(Throwable cause) {
        super(cause);
    }

    /**
     * 构造：API请求异常
     * @param message 错误信息
     * @param cause 错误对象
     */
    public ApiException(String message, Throwable cause) {
        super(message, cause);
    }

}
